package com.yunxun.coinmessage.dao;

import com.yunxun.coinmessage.entity.MesSource;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface MesSourceDao {

     @Insert("insert into mesSource(cpid,sname,typeId) values(#{cpid},#{sname},#{typeId})")
     @Options(useGeneratedKeys = true, keyProperty = "sid" ,keyColumn = "sid")
     void addMesSource(MesSource mesSource);



     @Select("select count(*) from mesSource where status=1")
     Integer queryTotal();



     @Select("select * from mesSource where status=1")
     List<MesSource> queryAll();

     @Update("update mesSource set status=0 where sid=#{sid}")
     Integer  deleteById(Integer sid);


     @Select("select * from mesSource where sid=#{sid}")
     MesSource queryByid(Integer sid);

     @Update("update mesSource set cpid=#{cpid},sname=#{sname},typeId=#{typeId} where sid=#{sid}")
     void updateById(MesSource mesSource);

     //按类型查询渠道
     @Select("select * from mesSource where typeId=#{typeId} and status=1")
     List<MesSource> queryByTypeId(Integer typeId);

     //按分类查询渠道
     @Select("select * from mesSource where cpid=#{cpid} and status=1")
     List<MesSource> queryByClassifiedPacket(Integer cpid);

     @Select("select * from mesSource where sname=#{sname} and status=1")
     public  MesSource queryByName(String sname);
}
